import React from 'react'

function common(ComposeComponent) {
    class common extends React.Component {
        constructor(props){
            super(props)
            this.state = {
                //字典
                dic: {
                    address:[{id:'1',name:'大上虞'},{id:'2',name:'舟山'}]
                },
                depart: 1231
            }
        }
        componentWillMount(){
            console.log("start",this.props)
        }
        dicName = (dicId,key) =>{
            console.log("dic")
            let dicList = this.state.dic[key]
            let re = ''
            dicList.forEach((item)=>{
                if(dicId === item.id){
                    re += item.name
                }
            })
            return re
        } 
        departName = (departId) =>{
            let re = departId + this.state.depart
            return re
        }
        render() {
            return (
                <ComposeComponent {...this.props} {...this.state} dicName={this.dicName} departName={this.departName}/>
            );
        }
    }
    return common;
}

export { common }
